package com.company.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.company.common.annotation.Log;
import com.company.common.core.controller.BaseController;
import com.company.common.core.domain.AjaxResult;
import com.company.common.enums.BusinessType;
import com.company.system.domain.TableRecruit;
import com.company.system.service.ITableRecruitService;
import com.company.common.utils.poi.ExcelUtil;
import com.company.common.core.page.TableDataInfo;

/**
 * 职位发布管理Controller
 * 
 * @author ruoyi
 * @date 2022-07-06
 */
@RestController
@RequestMapping("/system/recruit")
public class TableRecruitController extends BaseController
{
    @Autowired
    private ITableRecruitService tableRecruitService;

    /**
     * 查询职位发布管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:recruit:list')")
    @GetMapping("/list")
    public TableDataInfo list(TableRecruit tableRecruit)
    {
        startPage();
        List<TableRecruit> list = tableRecruitService.selectTableRecruitList(tableRecruit);
        return getDataTable(list);
    }

    /**
     * 导出职位发布管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:recruit:export')")
    @Log(title = "职位发布管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TableRecruit tableRecruit)
    {
        List<TableRecruit> list = tableRecruitService.selectTableRecruitList(tableRecruit);
        ExcelUtil<TableRecruit> util = new ExcelUtil<TableRecruit>(TableRecruit.class);
        util.exportExcel(response, list, "职位发布管理数据");
    }

    /**
     * 获取职位发布管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:recruit:query')")
    @GetMapping(value = "/{recruitid}")
    public AjaxResult getInfo(@PathVariable("recruitid") Long recruitid)
    {
        return AjaxResult.success(tableRecruitService.selectTableRecruitByRecruitid(recruitid));
    }

    /**
     * 新增职位发布管理
     */
    @PreAuthorize("@ss.hasPermi('system:recruit:add')")
    @Log(title = "职位发布管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TableRecruit tableRecruit)
    {
        return toAjax(tableRecruitService.insertTableRecruit(tableRecruit));
    }

    /**
     * 修改职位发布管理
     */
    @PreAuthorize("@ss.hasPermi('system:recruit:edit')")
    @Log(title = "职位发布管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TableRecruit tableRecruit)
    {
        return toAjax(tableRecruitService.updateTableRecruit(tableRecruit));
    }

    /**
     * 删除职位发布管理
     */
    @PreAuthorize("@ss.hasPermi('system:recruit:remove')")
    @Log(title = "职位发布管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recruitids}")
    public AjaxResult remove(@PathVariable Long[] recruitids)
    {
        return toAjax(tableRecruitService.deleteTableRecruitByRecruitids(recruitids));
    }
}
